﻿/*
  Project:       
  File:          ResigterDate.cs
  Description:   
 *               
 *               
 *               
  Author:        Lanny
  Date:          Aug,2014
  version:       2.0
  Modify:
 
                 
 Comments:
 * 1. Need to be tested in multi-network adapter scenarios.

 
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLL;

namespace TaoBaoProject.Handlers.RegisterHandler
{
  /// <summary>
  /// Summary description for RegisterDate
  /// </summary>
  public class RegisterDate : IHttpHandler
  {
    protected static readonly log4net.ILog log =
   log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    public void ProcessRequest(HttpContext context)
    {
      context.Response.ContentType = "text/plain";
      string qq, shopidStr;
      int shopID;

      shopID = 0;
      qq = context.Request.QueryString["qq"].ToString();
      shopidStr = context.Request.QueryString["shop"].ToString();
      ShopBLL shop = new ShopBLL();
      try
      {
        if (shopidStr != "")
        {
          if (!Common.Utility.CheckAllAreNumbers(shopidStr))
          {
            if (shopidStr.Contains(','))
            {
              shopidStr = shopidStr.Remove(shopidStr.LastIndexOf(','));
              shopID = shop.getShopId(shopidStr);
            }
            else
            {
              shopID = shop.getShopId(shopidStr);
            }
          }
          else
            shopID = Convert.ToInt32(shopidStr);

          //看看最近15天是否有录入数据~~
          if (RegisterBLL.GetRegister(qq, shopID, 15).Rows.Count < 1)
          {
            context.Response.Write("false");
          }
          else
          {
            context.Response.Write("true");
          }
        }
        else
        {
          log.Error("发现 传入的 shopidStr 字段值为空值！");
          context.Response.Write("error");
        }

      }
      catch (Exception ex)
      {
        log.Error("发现异常：" + ex.Message + "输入的QQ：" + qq + " 和shopid： " + shopidStr);
      }
    }

    public bool IsReusable
    {
      get
      {
        return false;
      }
    }
  }
}